<template>
    <orh-table
        pages :pageDate="pageDate"
        @on-page-change="Information"
		reload  @on-reload="refresh" search :searchOption="typeliat"  :searchOptionSelected="searchOptionSelected" @on-search="searchmt">
        <Table :data="StudentList" :columns="columns1" highlight-row  :loading="tableload" slot="table"></Table>
        <orh-sidebar v-model="show" :title="pageTitle" cover slot="others">
          <component :is='"Operation"' :typeother="'all'" :infoId='infoId' @showParent='showParent=>show=showParent' @backList='backList'></component>
        </orh-sidebar>
    </orh-table>
</template>
<script>
  export default {
    name: "studentfilesmodule-studentsday",
    components: {
        Operation: resolve => {require(['./../StudentBasicInformation/Operation.vue'], resolve);},
    },
    data () {
      return {

            searchOptionSelected: 'student_name',
            typeliat: [
				{
					value: 'student_name' ,
					label: '姓名',
				},
				{
					value: 'student_learncode' ,
					label: '学号',
				},
				{
					value: 'identityard_num' ,
					label: '身份证号',
				},
			],

            tableload:true,
			show: false,

			listUrl:'api/student/information/page/getStudentByLearninfo?way_to_study=0&page=',

            pageDate: {
              total: 0,
              current_page: 1,
              per_page: 10
            },
            pageTitle:null,//右边页面的title


            StudentList:[],//学生变量
			infoId: null,//用于向修改页面传id值


            columns1: [
				{
					title: "学号",
					width: 180,
					key: "student_learncode"
				},
				{
					title: "姓名",
					width: 120,
					render: (h, params) => {
						let sexname = params.row.student_name.zh
							? params.row.student_name.zh
							: params.row.student_name.mn;
						return h("div", sexname);
					}
				},
				{
					title: "性别",
					width: 80,
					render: (h, params) => {
						let sexname = params.row.sexs === 14 ? '男' : '女'
						return h("div", sexname);
					}
				},
				{
					title: "出生年月",
					width: 150,
					key: "birthday"
				},
				{
					title: "身份证号",
					width: 180,
					key: "idcard"
				},
				{
					title: ' ',
				},
				// {
				// 	title: '操作',
				// 	key: 'operation',
				// 	fixed: 'right',
				// 	width: 80,
				// 	align: 'center',
				// 	render: (h, params) => {
				// 		return h('div', [
				// 			h('Button', {
				// 				directives: [
				// 					{
				// 						name: "button",
				// 						value: "edit"
				// 					}
				// 				],
				// 				props: {
				// 					type: 'primary',
				// 					size: 'small'
				// 				},
				// 				style: {
				// 					marginRight: '5px',
				// 				},
				// 				on: {
				// 					click: () => {
				// 					this.update(params.row.student_base_id)
				// 					}
				// 				}
				// 			}, '编辑'),
				// 		]);
				// 	}
				// }
            ],
        }
    },
    methods: {

        /************************************************************
         *
         * 获取学生的数据
         *
         ************************************************************/
        Information(index=1){
            this.tableload=true
            this.StudentList=[]
            this.$http.get(this.listUrl + index + '&limit=10').then(val=>{
				console.log(val, 'data')
				this.StudentList = val.data
				this.pageDate.total = val.count;
				// this.pageDate.per_page = val.limit;
				this.pageDate.current_page = index;
                this.tableload = false//加载完数据动画结束               
            }).catch(err=>{
				if(err.code && err.code==422) {
					this.$Message.error(err.message);
				}
				this.tableload=false//加载完数据动画结束
            })
        },


        /************************************************************
         *
         * 点击编辑
         *
         ************************************************************/
        update(index){
            this.infoId = index
            this.show=true
			this.which_to_show='Operation'
            this.pageTitle='修改'
		},

        /************************************************************
         *
         * 修改添加返回数据更新
         *
         ************************************************************/
        backList(val,student_base_id){
            if(val == true){
				this.infoId=student_base_id
				this.Information();
            }
		},

        /************************************************************
         *
         * 刷新数据（当前分页）
         *
         ************************************************************/
        refresh(){
            this.Information()
        },

        /************************************************************
         *
         * 搜索操作
         *
         ************************************************************/
		searchmt(str,val) {
			let name = {
				zh: str
			}

			this.listUrl = `api/student/information/page/getStudentByLearninfo?way_to_study=0&${val}=
			${val === 'student_name' ? JSON.stringify(name) : str}&page=`
			this.Information(this.type);
			this.Information()
		},

    },
    mounted () {
		this.Information()

    }
}
</script>
